<!--<?php
print <<<EOT
-->

<script src="css/edit.js"></script>
<script>
<!--

function validate(tform) {

    var id_ary = $js_id_ary_str;
    var qty_flag = 0;
    
    for (var i=0; i<id_ary.length; i++) {
        
        if (document.all('p_num['+id_ary[i]+']').value != '' && isDigit(document.all('p_num['+id_ary[i]+']').value) && parseInt(document.all('p_num['+id_ary[i]+']').value) > 0) {
            qty_flag = 1;            
        }       
    }
    
    if (qty_flag == 0) {
        alert('Please enter the order qty !');
        return false;
    }
    
    return true;
   
}

function addWishlist(id, code) {
    url = "wishlist_view.php?act=add&pid="+id+"&code="+code;
    document.getElementById('addwishlistiframe').src=url;
}


function addCart(id) {
    var buy_num = $("#txtPNum"+id).val();
    var fitemid = $("#selFinish"+id).val();
    if(fitemid == 0 && $("#selFinish"+id).children().size() > 0)
    {
        alert('Please select a finish!');
        $("#selFinish"+id).focus();
        return false;
    }
    else if (!IsNumber(buy_num)||buy_num==0) {
        alert('请输入订购数量！');
        $("#txtPNum"+id).focus();
        return false;
    } else {
        url = "cart_view.php?act=add&inventorytype=0&inventoryid=0&pid="+id+"&js=1&addnum="+buy_num+"&fitemid="+fitemid;
        document.getElementById('addtocontentiframe').src=url;
    }
}

//-->
</script>

         $postiondiv 
	            <div class="main_search">					 
                $page_search
                <div align="center" class="paging_bar">{$PagerString}</div>
	            </div>
                 <div class="main">	 
                 <div class="lst_nav">	               
	           $category_list     
			    {$EnglishLink}		     
                 	 <br/>
                  <br/>  
                 </div>
                <div class="lst_listing">
                  <table width="740" border="0" cellspacing="0" cellpadding="0">
                    <tr>
                      <td width="5"><img name="" src="./images/spacer.gif" width="5" height="5" alt=""></td>
                      <td bgcolor="FFFFFF" width="10"><img name="" src="./images/spacer.gif" width="10" height="10" alt=""></td>
                      <td bgcolor="FFFFFF" width="548"><div><img name="" src="./images/spacer.gif" width="538" height="5" alt=""></div>
                      
                        <table width="538" border="0" cellspacing="0" cellpadding="0">                          
                          <tr>
                            <td align="center" class="pageTitleText">{$page_show['str']}</td>
                          </tr>                          
                        </table>
                        <div><img name="" src="./images/spacer.gif" width="538" height="5" alt=""></div></td>                     
                    </tr>
                  </table>
                  
                  <div>
                  <img name="" src="./images/spacer.gif" width="568" height="4" alt=""></div>
                  <form action="cart_view.php" method="post" name="form1" onSubmit="return validate(this)" target="addtocontentiframe">
    	    	  <input type="hidden" name="act" value="adddate">
    	    	  <input type="hidden" name="inventoryid" value="0">
    	    	  <input type="hidden" name="inventorytype" value="0">
    	    	  <input type="hidden" name="intype" value="0">
    	    	  <input type="hidden" name="js" value="1">
                  <table width="745" border="0" cellspacing="0" cellpadding="0">
                    <tr>
                      <td width="5"></td>
                      <td width="136"></td>
                      <td width="136"></td>
                      <td width="136"></td>
                      <td width="136"></td>
                      <td width="4"></td>
                    </tr>
                    <tr>
                      <td width="5"><img name="" src="./images/spacer.gif" width="5" height="5" alt=""></td>

               
<!--
EOT;
$index = 1;
$htmlTRFormat = '<tr><td height="18" width="35">%s</td><td width="5" align="center"></td><td>%s</td></tr>';

foreach ($product_ary as $k=>$v) {
    $str = '';
    if ($index%4 == 0 && $index>3) {
        $str       = '<td width="4"><img name="" src="./images/spacer.gif" width="4" height="4" alt=""></td>
                    </tr>
                    
                    <tr>
                      <td width="5"><img name="" src="./images/spacer.gif" width="5" height="5" alt=""></td>
                      <td align="left"><img name="" src="./images/spacer.gif" width="136" height="4" alt=""></td>
                      <td align="left"><img name="" src="./images/spacer.gif" width="136" height="4" alt=""></td>
                      <td align="left"><img name="" src="./images/spacer.gif" width="136" height="4" alt=""></td>
                      <td align="left"><img name="" src="./images/spacer.gif" width="136" height="4" alt=""></td>
                      <td width="4"><img name="" src="./images/spacer.gif" width="4" height="4" alt=""></td>
                    </tr>
                    <tr>
                      <td width="5"><img name="" src="./images/spacer.gif" width="5" height="5" alt=""></td>';
        
    } else {
        $str = '';    
    }
    $start_limit_1 = $start_limit+$index;
    if (trim($v['small_pic']) == "" || !file_exists("attachments/" . $v['small_pic'])) {
        $v['small_pic'] = 'noCN.gif';
    }
    /*
    $price_show = '';
    if ($jansen_type==2) {
    	$v['price_2'] = number_format($v['price_2'], 2, '.', ',');
    	$price_show = '<div>美金 : ' . $v['price_2'] . '</div>';
    } elseif ($jansen_type == 1) {
    	$v['price_3'] = number_format($v['price_3'], 2, '.', ',');
    	$price_show = '<div>HKD : ' . $v['price_3'] . ' </div>';
    }
    */
    $price_show = '';    
    
    if ($v['search_type'] == 'inventory') {
        if ($jansen_type==2) {
            $sp = isset($sp_ary[$v['id']][$v['inventory_id']]) ? $sp_ary[$v['id']][$v['inventory_id']] : 0;
    
            $sp = number_format($sp, 2, '.', ',');
            if ($sp == 0) {
                $sp_div = '';
            } else {
                $sp = number_format($sp, 2, '.', ',');
                /* $sp_div = '<div class="price">Special: ' . $sp . ' 美金</div>'; */
                $sp_div = sprintf($htmlTRFormat,'Special',$sp.' 美金');
            }
            $show_text = $sp==0 ? "Price" : "Regular";
            if ($inventory_type == 2) {
                //$sp = $sp==0 ? ' - ' : (float)$sp . '';
                $v['price_2'] = number_format($v['price_2'], 2, '.', ',');
                /* $price_show = '<div class="price">' . $show_text . ': ' . $v['price_2'] . ' 美金</div>
    	                       ' . $sp_div; */
    	        $price_show = sprintf($htmlTRFormat,$show_text,$v['price_2'].' 美金').$sp_div;               
            } else {
                //$sp = $sp==0 ? ' - ' : (float)$sp . '';
                $v['price_1'] = number_format($v['price_1'], 2, '.', ',');
                //$price_show = '<div class="price">' . $show_text . ': ' . $v['price_1'] . ' 美金</div>' . $sp_div;
                 $price_show = sprintf($htmlTRFormat,$show_text,$v['price_1'].' 美金').$sp_div;
            }
        	
        } elseif ($jansen_type == 1) {
            $sp = isset($sp_ary2[$v['id']][$v['inventory_id']]) ? $sp_ary2[$v['id']][$v['inventory_id']] : 0;
            $sp = number_format($sp, 2, '.', ',');
            if ($sp == 0) {
                $sp_div = '';
            } else {
                $sp = number_format($sp, 2, '.', ',');
                //$sp_div = '<div class="price">Special: ' . $sp . ' HKD</div>';
                $sp_div = sprintf($htmlTRFormat,'Special',$sp.' HKD');
            }
            $show_text = $sp==0 ? "Price" : "Regular";
            $v['price_3'] = number_format($v['price_3'], 2, '.', ',');
        	//$price_show = '<div class="price">' . $show_text . ': ' . $v['price_3'] . ' HKD</div>
    	    //               ' . $sp_div;
    	    $price_show = sprintf($htmlTRFormat,$show_text,$v['price_3'].' HKD').$sp_div;                 
        }
        //$qty_show = '<div class="price">Available Qty:&nbsp;' . $product_qty_ary[$v['id']][$v['inventory_id']] . '</div>';
        $qty_show = sprintf($htmlTRFormat,'Available Qty',$product_qty_ary[$v['id']][$v['inventory_id']]);
        
        $href = 'inventory_details.php?inventoryid=' . $v['inventory_id'] . '&categoryid=' . $product_category_ary[$v['id']] . '&pid=' . $v['id'];
    } else {
        if ($jansen_type==2) {
            $v['price_2'] = number_format($v['price_2'], 2, '.', ',');
            //$price_show = '<tr><td height="25"> 美金</td><td width="5" align="center"></td><td> ' . $v['price_2'] . '</td></tr>';
            $price_show = sprintf($htmlTRFormat,'美金',$v['price_2']);
        } elseif ($jansen_type == 1) {
            $v['price_3'] = number_format($v['price_3'], 2, '.', ',');
            //$price_show = '<tr><td height="25"> HKD</td><td width="5" align="center"> </td><td> ' . $v['price_3'] . '</td><tr/>';
            $price_show = sprintf($htmlTRFormat,'HKD',$v['price_3']);
        }
        $qty_show = '<br>';
        $href = 'product_details.php?categoryid=' . $product_category_ary2[$v['id']] . '&pid=' . $v['id'];
    }
	 $product_name_show = '';
	/*if($v['namezh']!='')
	{
		$product_name_show = '<div style=\"min-height:30px;height:30px;overflow:hidden;line-height:15px;\">'.$v['namezh'].'</div>';
	}
	else if($v['name']!='')
	{
	  $product_name_show = '<div style=\"min-height:30px;height:30px;overflow:hidden;line-height:15px;\">'.$v['name'].'</div>';
	}*/
	$product_name_show = '<div style=\"min-height:30px;height:30px;overflow:hidden;line-height:15px;\">'.$v['namezh'].'</div>';
	
    $new_show = '';
    if ($v['new_flag'] == 1) {
        $new_show = '&nbsp;&nbsp;<span class="new_show">新产品!</span>';
    }
	   $productName=$product_info_ary['namezh']==""?$product_info_ary['name']:$product_info_ary['namezh'];
	
print <<<EOT
-->    	

    	              <td align="center">
    	                <table width="150" border="0" cellspacing="0" cellpadding="0">
                          <tr>
                            <td bgcolor="FFFFFF" width="10"><img name="" src="./images/spacer.gif" width="10" height="10" alt=""></td>
                            <td bgcolor="FFFFFF" width="145"><img name="" src="./images/spacer.gif" width="115" height="10" alt=""></td>
                            
                          </tr>
                          <tr valign=top>
                            <td bgcolor="FFFFFF" width="10"><img name="" src="./images/spacer.gif" width="10" height="10" alt=""></td>
                            <td bgcolor="FFFFFF" width="145"><div><a href='$href'><img src="attachments/{$v['small_pic']}" alt="Image of {$v['id']}" name="jf_product_images_sm_image_{$v['id']}" width="113" height="113" class="picture" id="jf_product_images_sm_image_{$v['id']}" border="0"></a></div>
                              <div><img src="./images/spacer.gif" width="115" height="5" alt=""></div>
                              <!--div align="left"><a href='product_details.php?categoryid=$categoryid&pid={$v['id']}&fid=$fid'>{$v['code']}</a>  {$new_show}</div-->
                              <div align="left"><a href='{$href}'>{$v['code']}</a>  {$new_show} </div>
							  
                              <div><img src="./images/spacer.gif" width="115" height="5" alt=""></div>
                              <!--div><a href="" onMouseOver="MM_swapImage('jf_button_view_image_{$v['id']}','','./images/button/jf_button_view_image-over.gif',1)" onMouseOut="MM_swapImgRestore()"><img src="./images/button/jf_button_view_image.gif" alt="View Image for item " name="jf_button_view_image_{$v['id']}" width="115" height="15" border="0" id="jf_button_view_image_{$v['id']}"></a></div-->
                              <!--div>{$v['inventory_id']}</div-->
                         <!--    $product_name_show-->
							 $product_name_show
							
                             <div>
                              <table cellspacing="0" cellpadding="0">
                              <tbody>
                               $price_show  
                               <tr><td height="25" width="35" >漆色</td>
                                      <td width="5" align="center"></td>
                                      <td><select style="width: 75px;height:17px; padding:0; margin:0;" id='selFinish{$v["id"]}' name='selFinish{$v["id"]}'>{$_finish[$v["finish_id"]]}</select></td>
                               </tr>
                               <tr>
                                  <td height="25">数量</td>
                                  <td width="5" align="center"></td>
                                  <td><input type="text" id="txtPNum{$v['id']}" name="txtPNum{$v['id']}" style="width:75px;height:17px; padding:0; margin:0;" />   </td>
                              </tr>
                               <tr>
                                  
                                  <td height="25" colspan="3">
                                  <div class="addtocart" ><a href="javascript:;" onclick="addCart({$v['id']});">加到购物车</a>
                                 <!-- <a href="javascript:;" onclick="addWishlist('{$v['id']}', '{$v['code']}');">Add to Container</a>-->
                                 </div></td>
                                  
                              </tr>
                              </tbody></table>
                              
                              </div>
                            
                            </td>
                            
                          </tr>
                          <tr>
                            <td bgcolor="FFFFFF" width="10"><img name="" src="./images/spacer.gif" width="10" height="10" alt=""></td>
                            <td bgcolor="FFFFFF" width="145"><img name="" src="./images/spacer.gif" width="115" height="10" alt=""></td>
                            
                          </tr>
                         
                        </table>
                      </td>
                      $str

<!--
EOT;
    $index++;
} 
print <<<EOT
-->                                                          
                      
                      <td width="4"><img name="" src="./images/spacer.gif" width="4" height="4" alt=""></td>
                    </tr>
                    
                    <tr>
                      <td width="5"><img name="" src="./images/spacer.gif" width="5" height="5" alt=""></td>
                      <td align="left"><img name="" src="./images/spacer.gif" width="136" height="4" alt=""></td>
                      <td align="left"><img name="" src="./images/spacer.gif" width="136" height="4" alt=""></td>
                      <td align="left"><img name="" src="./images/spacer.gif" width="136" height="4" alt=""></td>
                      <td align="left"><img name="" src="./images/spacer.gif" width="136" height="4" alt=""></td>
                      <td width="4"><img name="" src="./images/spacer.gif" width="4" height="4" alt=""></td>
                    </tr>
                    
<!--
EOT;
if (!empty($product_ary) && false) {
print <<<EOT
-->                     
                    
                    <!--tr height=20 valign-"middle"><td colspan=5 align="right">
                    <input type="image" onMouseOver="MM_swapImage('jf_button_add_all_to_cart','','./images/button/jf_button_add_all_to_container-over.gif',1)" onMouseOut="MM_swapImgRestore()" src="./images/button/jf_button_add_all_to_container.gif" alt="Login" name="jf_button_add_all_to_cart" width="120" height="20" border="0" id="jf_button_add_all_to_cart">&nbsp;
                    </td>
                    
                    <td width="4">
                    </td>
                    </tr-->
                  
<!--
EOT;
} 
print <<<EOT
-->            
                    
                  </table>
                  </form> 
                 
       
                  
                  <div><img name="" src="./images/spacer.gif" width="568" height="4" alt=""></div>
                  
                  <iframe name='addwishlistiframe' width=0 height=0 src="about:blank" id='addwishlist' style="display:none;"></iframe>
                  <iframe name='addtocontentiframe' width=0 height=0 src="about:blank" id='addtocontentiframe'  style="display:none;"></iframe>
                  
                  <div><img name="" src="./images/spacer.gif" width="10" height="2" alt=""></div></td>
                <td background="./images/colour/jf_colour_navy_100.gif" width="1"><img name="" src="./images/spacer.gif" width="1" height="1" alt=""></td>
              </tr>             
            </table>
                </div>
         <div class="main_search" style="clear:both;" id="footPage">	
          <div  class="paging_bar">{$PagerString}</div>  	      
	    </div> 
       </div> 
       
 	
 	 
	
        
<!--
EOT;
?>-->